/*
  June 2012

  BaseFlightPlus Rev -

  An Open Source STM32 Based Multicopter

  Includes code and/or ideas from:

  1)AeroQuad
  2)BaseFlight
  3)CH Robotics
  4)MultiWii
  5)S.O.H. Madgwick

  Designed to run on Naze32 Flight Control Board

  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

///////////////////////////////////////////////////////////////////////////////
// MPU3050 Variables
///////////////////////////////////////////////////////////////////////////////

#define GYRO_SCALE_FACTOR     0.00121414f       //  MPU3050 14.375 LSBs per dps

extern uint8_t gyroCalibrating;

extern float gyroRTBias[3];

extern float gyroTCBias[3];

extern int32_t gyroSum100Hz[3];

extern int32_t gyroSum200Hz[3];

extern int32_t gyroSum500Hz[3];

extern int32_t gyroSummedSamples100Hz[3];

extern int32_t gyroSummedSamples200Hz[3];

extern int32_t gyroSummedSamples500Hz[3];

extern float gyroTemperature;

extern int16andUint8_t rawGyro[3];

extern int16andUint8_t rawGyroTemperature;

///////////////////////////////////////////////////////////////////////////////
// Read Gyro
///////////////////////////////////////////////////////////////////////////////

void readGyro(void);

///////////////////////////////////////////////////////////////////////////////
// Compute Gyro Temperature Compensation Bias
///////////////////////////////////////////////////////////////////////////////

void computeGyroTCBias(void);

///////////////////////////////////////////////////////////////////////////////
// Compute Gyro Runtime Bias
///////////////////////////////////////////////////////////////////////////////

void computeGyroRTBias(void);

///////////////////////////////////////////////////////////////////////////////
// Gyro Initialization
///////////////////////////////////////////////////////////////////////////////

void initGyro(void);

///////////////////////////////////////////////////////////////////////////////
